package com.bldby.baselibrary.app.upload;

import com.alibaba.fastjson.TypeReference;
import com.bldby.baselibrary.core.network.AbsApiRequest;
import com.bldby.baselibrary.core.network.BaseApiRequest;
import com.bldby.baselibrary.core.network.ParamsBuilder;
import com.bldby.baselibrary.core.network.RequestLevel;

import java.io.File;
import java.util.ArrayList;

public class UploadRequest extends BaseApiRequest {
    //    user//
//    good//
//   merchant//
    private ArrayList<File> files = new ArrayList<>();
    public String filedir;

    public ArrayList<File> addFile(File f) {
        files.add(f);
        return files;
    }

    @Override
    public String getAPIBaseURL() {
        return null;
    }

    @Override
    public String getAPIName() {
        return "files/upload";
    }

    @Override
    public RequestLevel getRequestLevel() {
        return RequestLevel.POST;
    }

    @Override
    public TypeReference getResponseType() {
        return null;
    }

    @Override
    public ParamsBuilder appendParams(ParamsBuilder builder) {
        builder.append("files", files);
        builder.append("filedir", filedir);
        return super.appendParams(builder);
    }

    @Override
    public TypeReference getDatatype() {
        return new TypeReference<Result>() {
        };
    }

    public static class Result {
        public String fileName;
        public String url;
    }
}
